package com.cloud.logger.zchain.zchainserver.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

/**
 * User: wcy
 * Date: 2017/11/8
 * Time: 13:25
 */
@Data
@Document(collection = "logger")
public class AngelaLogger {
    @Id
    private String id;
    //给子节点使用
    @JsonProperty("uuid")
    @JSONField(name = "uuid")
    @ApiModelProperty(name = "uuid", notes = "给子节点使用", example = "1")
    private String uuid;
    //接口名
    @JsonProperty("interface_name")
    @JSONField(name = "interface_name")
    @ApiModelProperty(name = "interface_name", notes = "接口名称", example = "1")
    private String interfaceName;
    //接口ip地址
    @JsonProperty("interface_ip")
    @JSONField(name = "interface_ip")
    @ApiModelProperty(name = "interface_ip", notes = "接口ip地址", example = "1")
    private String interfaceIp;
    //接口ipport
    @JsonProperty("interface_port")
    @JSONField(name = "interface_port")
    @ApiModelProperty(name = "interface_port", notes = "接口端口", example = "80")
    private Integer interfacePort;
    @JsonProperty("create_time")
    @JSONField(name = "create_time", format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(name = "create_time", notes = "创建时间", example = "2017-11-09 09:01:01")
    private Date createTime;
    @JsonProperty("updateTime")
    @JSONField(name = "updateTime", format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(name = "updateTime", notes = "更新时间", example = "2017-11-09 09:01:01")
    private Date updateTime;
    //消耗时间
    @JsonProperty("elapsed_time")
    @JSONField(name = "elapsed_time")
    @ApiModelProperty(name = "elapsed_time", notes = "消耗时间", example = "100")
    private Long elapsedTime;
    //客户请求ip
    @JsonProperty("source_iP")
    @JSONField(name = "source_iP")
    @ApiModelProperty(name = "source_iP", notes = "客户请求ip", example = "localhost")
    private String sourceIP;
    //请求参数
    @JsonProperty("parms")
    @JSONField(name = "parms")
    @ApiModelProperty(name = "parms", notes = "请求参数", example = "{}")
    private String parms;
    //请求结果
    @JsonProperty("result")
    @JSONField(name = "result")
    @ApiModelProperty(name = "result", notes = "请求结果", example = "{}")
    private String result;
    //所属类型(error,debugger,info)
    @JsonProperty("type")
    @JSONField(name = "type")
    @ApiModelProperty(name = "type", notes = "所属类型(error,debugger,info)", example = "info")
    private String type;
    //请求方式（INTERCEPTOR，HTTPCLIENT, LOGGER）
    @JsonProperty("pattern")
    @JSONField(name = "pattern")
    @ApiModelProperty(name = "pattern", notes = "请求方式（INTERCEPTOR，HTTPCLIENT, LOGGER）", example = "INTERCEPTOR")
    private String pattern;
    //状态(8200,8500,200,500,404等)
    @JsonProperty("status")
    @JSONField(name = "status")
    @ApiModelProperty(name = "status", notes = "状态(8200,8500,200,500,404等)", example = "8500")
    private String status;
    //警报等级（1：正常，2：警报，3：错误，4：严重错误）
    @JsonProperty("alarm_level")
    @JSONField(name = "alarm_level")
    @ApiModelProperty(name = "alarm_level", notes = "警报等级（0：正常，1：异常，2：警报，3：错误，4：严重错误", example = "1")
    private Integer alarmLevel;
    @JsonProperty("parent_node")
    @JSONField(name = "parent_node")
    @ApiModelProperty(name = "parent_node", notes = "父节点()", example = "xxxx")
    //父节点的uuid，rpc或者httpclient请求时使用（拦截器时为空）
    private String parentNode;
    //HTTP请求消息中的请求方式
    @JsonProperty("method")
    @JSONField(name = "method")
    @ApiModelProperty(name = "method", notes = "HTTP请求消息中的请求方式", example = "POST")
    private String method;
    //所属景区
    @JsonProperty("scenic")
    @JSONField(name = "scenic")
    @ApiModelProperty(name = "scenic", notes = "景区名称", example = "西溪湿地")
    private String scenic;
    //所属项目
    @JsonProperty("project")
    @JSONField(name = "project")
    @ApiModelProperty(name = "project", notes = "项目名称", example = "西溪湿地管控")
    private String project;
    //接口描述
    @JsonProperty("description")
    @JSONField(name = "description")
    @ApiModelProperty(name = "description", notes = "接口描述", example = "保存接口")
    private String description;

    @JsonProperty("zchain_client_time")
    @JSONField(name = "zchain_client_time", format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(name = "zchain_client_time", notes = "客户端时间", example = "2017-11-09 09:01:01")
    private Date zchainClientTime;

    @Transient
    private List<AngelaLogger> children;
}
